<template>
  <!--到货验收-->
  <div style="padding: 20px">
    <el-card class="box-card">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="全部" name="first"><el-button @click="handleNew">新增</el-button>
          <el-button @click="handleDelete">删除</el-button>
          <el-input placeholder="请输入设备编号或名称" clearable prefix-icon="el-icon-search" suffix-icon="el-icon-s-cale"
            style="width: 250px; margin-left: 660px" />
          <el-popover placement="right" width="400" trigger="click">
            <svg-icon icon-class="caiss" style="width: 40px; height: 20px" class="pointer" slot="reference" />
          </el-popover>
          <el-table size="medium" :data="data" style="width: 100%; margin-top: 20px" @cell-click="cellHandleclick"
            :cell-style="tableCellStyle">
            <el-table-column type="selection" width="55" align="center" fixed />
            <el-table-column prop="序号" label="序号" width="55" align="center" fixed>
              <template v-slot="scope">
                {{ scope.$index + 1 }}
              </template>
            </el-table-column>
            <el-table-column label="操作" width="55" align="center" fixed>
              <template v-slot="scope">
                <el-button type="text" @click="handleView(scope.row)">查看</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="state" label="状态" width="80" align="center">
              <template slot-scope="scope">
                <el-tag type="success" effect="dark" v-if="scope.row.state == 0">未入档</el-tag>
                <el-tag type="warning" effect="dark" v-if="scope.row.state == 2">部分入档</el-tag>
                <el-tag type="danger" effect="dark" v-if="scope.row.state == 3">已入档</el-tag>
              </template>
            </el-table-column>
            <el-table-column prop="code" label="验收单号" width="150" align="center" />
            <el-table-column prop="topic" label="验收主题" width="150" align="center" />
            <el-table-column prop="date" label="验收日期" width="120" align="center" />
            <el-table-column prop="department" label="验收部门" width="100" align="center" />
            <el-table-column prop="acceptor" label="验收人员" width="100" align="center" />
            <el-table-column prop="purchase" label="采购单号" style="color: red" width="180" align="center" />
            <el-table-column prop="remark" label="备注" width="180" align="center" />
          </el-table>

          <el-pagination background style="margin-top: 20px; text-align: right" :page-size="10" :total="45"
            layout="prev, pager, next, sizes, total" :page-sizes="[10, 20, 30, 50]" /></el-tab-pane>
        <el-tab-pane label="我的申请" name="second">我的申请</el-tab-pane>
        <el-tab-pane label="我的审批" name="third">我的审批</el-tab-pane>
      </el-tabs>
    </el-card>
  </div>
</template>
<script>
import { SelectAllAcceptance } from "@/api/eastjet-maintenance/dao/dao";
export default {
  data() {
    return {
      //卡片信息
      activeName: "first",
      searchText: "",
      data: [
        // 添加更多数据
      ],
      currentPage: 1,
      pageSize: 10,
    };
  },
  created() {
    SelectAllAcceptance().then((res) => {
      this.data = res.data.data.list;
      console.log("数据", res)
    });
  },
  methods: {
    // 改变某一列单元格背景颜色
    tableCellStyle({ row, column, rowIndex, columnIndex }) {
      if (column.label === "采购单号") {
        //第3列字体颜色是红色
        return "color:red;!important;";
      }
    },
    cellHandleclick(row, column, cell, event) {
      //如果规定点击某一列执行，利用column中的label属性
      if (column.label === "采购单号") {
        //执行逻辑
        alert(11);
      }
    },
    //卡片选择信息
    handleClick(tab, event) {
      console.log("卡片", tab, event);
    },
    handleSearch() {
      this.currentPage = 1;
    },
    handleNew() {
      // 处理新增操作
      this.$router.push({ path: "/sb/yan/shou/xin" });
    },
    handleDelete() {
      // 处理删除操作
    },
    handleView(row) {
      // 查看具体信息
      this.$router.push({ path: "/sb/yan/shou/cha", query: { code: row.code, purchase: row.purchase } });
    },
    handlePageChange(page) {
      this.currentPage = page;
    },
  },
};
</script>
<style>
/* 自定义样式 */
.text {
  font-size: 14px;
}

.item {
  padding: 18px 0;
}

.box-card {
  width: 1210px;
  height: 660px;
  margin-left: 14px;
}
</style>
